#include "Entity.h"

Entity::Entity(std::pair<int,int> positionE, int idE, int typeE)
{
    x = positionE.first;
    y = positionE.second;
    id = idE;
    type = typeE;
}

int Entity::distanceTo(std::pair<int,int> position)
{
    return 1;
}

int Entity::getType()
{
    return type;
}

int Entity::getId()
{
    return id;
}

std::pair<int,int> Entity::getPosition()
{
    std::pair<int,int> position;
    position.first = x;
    position.second = y;
    return position;
}

int Entity::maximumOffset(Entity *target)
{
    return std::max(abs(target->getPosition().first - x), abs(target->getPosition().second - y));
}

bool Entity::isNearby(Entity *target)
{
    return (maximumOffset(target) <= 1);
}

void Entity::setPosition(int xN, int yN)
{
    x = xN;
    y = yN;
}

std::string Entity::printC()
{
    std::string str;
    std::stringstream out;
    out << x;
    str += "\nPosition - "+out.str();
    out.str("");
    out << y;
    str += "\nPosition - "+out.str();
    out.str("");
    out << id;
    str += "\nId - "+out.str();
    out.str("");
    out << type;
    str += "\nType - "+out.str();
    out.str("");

    return str;
}
